//
//  line_top_bottom_uiview.swift
//  weile
//
//  Created by LKM on 16/10/25.
//  Copyright © 2016年 LKM. All rights reserved.
//

import UIKit

class line_top_bottom_uiview: UIView {
    
    /*
     // Only override draw() if you perform custom drawing.
     // An empty implementation adversely affects performance during animation.
     override func draw(_ rect: CGRect) {
     // Drawing code
     }
     */
    //代码得重新写。view的生命周期
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        line_top_bottom(self);
    }
    
    required init(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)!
        line_top_bottom(self);
    }
    
    var borderLayer:CAShapeLayer!;
    var bborderLayer:CAShapeLayer!;
    func line_top_bottom(_ v:UIView){
        borderLayer = CAShapeLayer();
        //        borderLayer.bounds = CGRectMake(0, 0, v.width, v.height);
        // borderLayer.frame = CGRect(x: 0, y: 0, width: v.width, height: 0.7);
        borderLayer.backgroundColor = R.colors.com_line.cgColor;
        
        v.layer.addSublayer(borderLayer);
        
        bborderLayer = CAShapeLayer();
        //        borderLayer.bounds = CGRectMake(0, 0, v.width, v.height);
        //bborderLayer.frame = CGRect(x: 0, y: v.height-0.7, width: v.width, height: 0.7);
        bborderLayer.backgroundColor = R.colors.com_line.cgColor;
        
        v.layer.addSublayer(bborderLayer);
    }
    override func layoutSubviews() {
        super.layoutSubviews()
        borderLayer.frame = CGRect(x: 0, y: 0, width: self.width, height: 0.7);
        bborderLayer.frame = CGRect(x: 0, y: self.height-0.7, width: self.width, height: 0.7);
    }
    
}
